package com.example.administrator.shzs.parse;

import com.alibaba.fastjson.JSON;
import com.example.administrator.shzs.entity.Integral;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * 积分实体类
 * Created by Administrator on 2016/10/25.
 */

public class ParseIntegral {

    public static List<Integral> getIntegral(String json) {
        List<Integral> list = new ArrayList<>();

        try {
            JSONObject jsonObject = new JSONObject(json);
            JSONArray array = jsonObject.getJSONArray("datalist");

            if (null != array && array.length() > 0) {

                for (int i = 0; i < array.length(); i++) {
                    list.add(JSON.parseObject(array.get(i).toString(), Integral.class));
                }
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return list;
    }

}
